Skip to content

Conversation

QuietMisdreavus
Copy link
Member

@QuietMisdreavus QuietMisdreavus commented Oct 2, 2017

This PR adds a new unstable flag to rustdoc, --crate-version, which when present will add a new entry to the sidebar of the root module, printing the given version number:

Screenshot of a test crate, showing "Version 1.3.37" under the crate name

Closes #24336

(The WIP status is because i don't want to merge this until i can get the std docs to use it, which i need help from rustbuild people to make sure i get right.)

@rust-highfive
Copy link
Contributor

Some changes occurred in HTML/CSS.

cc @GuillaumeGomez

@rust-highfive
Copy link
Contributor

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@QuietMisdreavus
Copy link
Member Author

QuietMisdreavus commented Oct 2, 2017

Pings for everyone!

@rust-lang/docs Does this look right? Is this a good place for this? Right now it only shows up on the root module's page - nothing else will show this. Should we put it everywhere?

@GuillaumeGomez and @steveklabnik specifically (possibly dev-tools more broadly, but for now i'll stick with rustdoc peers) - This is a new command-line flag. In dev-tools meeting today the prevailing air was that this was not RFC worthy since it was straightforward enough, but i want to make extra sure that the other rustdoc stakeholders are on board.

@alexcrichton @Mark-Simulacrum (other rustbuild experts?) - How can I get bootstrap to use this flag when rendering docs for std and friends?

@GuillaumeGomez
Copy link
Member

Seems to be good. What happens with a very long version name? Does it goes on two lines or does it just stick out of the sidebar?

@QuietMisdreavus
Copy link
Member Author

Looks like it wraps within the sidebar:

image

...unless you use a long word without a breaking separator, in which case it sticks out from the sidebar:

image

@GuillaumeGomez
Copy link
Member

This is a (smaaall) bug then. :p

@steveklabnik
Copy link
Member

This sounds good to me!

@shepmaster shepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 6, 2017
@camsteffen
Copy link
Contributor

Use these styles to fix the wrapping issue on most modern browsers.

overflow-wrap: break-word;
word-wrap: break-word; /* deprecated */
word-break: break-word; /* Chrome, non-standard */

@QuietMisdreavus
Copy link
Member Author

Wow, thanks! That looks much better!

image

I've force-pushed to include that CSS into the update.

@GuillaumeGomez
Copy link
Member

Now it's all good. Thanks!

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 9, 2017

📋 Looks like this PR is still in progress, ignoring approval

@GuillaumeGomez
Copy link
Member

Ah damn, well, r=me once done.

@QuietMisdreavus
Copy link
Member Author

Yeah, the rustdoc piece is basically done, but i'd like to see if i can get rustbuild to use this when generating the docs for std and friends before calling it done. I'll ask around again.

@Mark-Simulacrum
Copy link
Member

You'll need to edit src/bootstrap/builder.rs and add RUSTDOC_CRATE_VERSION to the rustdoc_cmd environment variables. The value can be pulled from channel::CFG_RELEASE_NUM (1.22.0) or if you want the SHA, self.build.rust_info.version(...) will work.

Let me know if you'd like more detailed instructions, or I can probably get you a commit implementing this within a few days.

@QuietMisdreavus QuietMisdreavus changed the title [WIP] let rustdoc print the crate version into docs let rustdoc print the crate version into docs Oct 9, 2017
@QuietMisdreavus
Copy link
Member Author

@Mark-Simulacrum That got me most of the way there. It turns out that the docs weren't using rustdoc_cmd at all, instead going through cargo. I wound up adding RUSTDOCFLAGS to each doc invocation to get the crate version in, but that can introduce problems in compiler-docs mode, since external crates will also get that version number. I also don't know how this will interact if/when Cargo starts providing this flag itself, but for the moment this does what i want:

image

If you think this is fine, then i'm ready to call this good.

@Mark-Simulacrum
Copy link
Member

Hm, I'm suspecting that RUSTDOCFLAGS may not apply correctly with compiler docs, since we want the version to display on more than just the last crate. I think I'd move to unconditionally setting something like RUSTDOC_CRATE_VERSION in cargo (src/bootstrap/builder.rs) and then using that in src/bin/rustdoc.rs to set the unstable option.

@QuietMisdreavus QuietMisdreavus force-pushed the what-is-your-quest branch 3 times, most recently from 21cb80a to 5a847c6 Compare October 10, 2017 00:23
@QuietMisdreavus
Copy link
Member Author

Ooh, i like that option. I've force-pushed with an update that uses that instead.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the rustbuild changes after this small nit.

@@ -574,6 +574,9 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
}

// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add this to rustdoc_cmd above to make certain it's passed in all cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force-pushed with this update.

@Mark-Simulacrum
Copy link
Member

@bors r=GuillaumeGomez

@bors
Copy link
Collaborator

bors commented Oct 11, 2017

📌 Commit 7ea286e has been approved by GuillaumeGomez

kennytm added a commit to kennytm/rust that referenced this pull request Oct 12, 2017
… r=GuillaumeGomez

let rustdoc print the crate version into docs

This PR adds a new unstable flag to rustdoc, `--crate-version`, which when present will add a new entry to the sidebar of the root module, printing the given version number:

![Screenshot of a test crate, showing "Version 1.3.37" under the crate name](https://user-images.githubusercontent.com/5217170/31104096-805e3f4c-a7a0-11e7-96fc-368b6fe063d6.png)

Closes rust-lang#24336

(The WIP status is because i don't want to merge this until i can get the std docs to use it, which i need help from rustbuild people to make sure i get right.)
bors added a commit that referenced this pull request Oct 12, 2017
[WIP] Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138
bors added a commit that referenced this pull request Oct 12, 2017
Rollup of 9 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45166, #45172, #45190, #45231
- Failed merges: #45138
@bors bors merged commit 7ea286e into rust-lang:master Oct 13, 2017
@QuietMisdreavus QuietMisdreavus deleted the what-is-your-quest branch October 13, 2017 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants